package com.zqp.web.aspect;

import java.util.Date;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * 
* @author zqp
* @version2017年12月19日 
* @description
 */
//@Aspect
//@Component
public class TimeAspect {

	/**
	 * 增强
	 * @param pjd
	 * @return
	 * @throws Throwable 
	 */
	@Around("execution(* com.zqp.web.controller.UserController.*(..))")
	public Object handlerControllerMehod(ProceedingJoinPoint pjd) throws Throwable {
		
		System.out.println("time aspect start ");
		long start = new Date().getTime();
		//参数
		Object[] args = pjd.getArgs();
		
		for (Object arg : args) {
			System.out.println("args is "+ arg);
		}
		//返回值
		Object proceed = pjd.proceed();
		
		System.out.println("timer aspect 耗时" + (new Date().getTime()  -start));
		System.out.println("timer aspect end");
		
		return null;
	}
}
